package com.heima.admin.controller.v1;

import com.heima.admin.service.AdNewsService;
import com.heima.model.admin.dtos.AdNewsDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
@RequiredArgsConstructor
public class AdNewsController {

    private final AdNewsService adNewsService;

    /**
     * 查询文章列表
     * @param dto
     * @return
     */
    @PostMapping("/list_vo")
    public ResponseResult list(@RequestBody AdNewsDto dto) {
        return adNewsService.findList(dto);
    }

    /**
     * 查询文章详情
     * @param id
     * @return
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult getOne(@PathVariable Integer id) {
        return ResponseResult.okResult(adNewsService.getById(id));
    }

    /**
     * 查询失败文章列表
     * @param dto
     * @return
     */
    @PostMapping("/auth_fail")
    public ResponseResult listFail(@RequestBody AdNewsDto dto) {
        return adNewsService.findList(dto);
    }

    /**
     * 查询成功文章列表
     * @param dto
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult listPass(@RequestBody AdNewsDto dto) {
        return adNewsService.findList(dto);
    }
}
